<?php defined('_JEXEC') or die('Restricted access');
$item = $this->auction;
$template = "templates/tpl_automobil/";
$user = JFactory::getUser();
$db = JFactory::getDBO();
$q = "SELECT image, image1, image2, image3, image4 FROM #__pr_product WHERE id = ".$item->product_id;
$db->setQuery($q);
$imageList = $db->loadRow();
$imgNum = 0;
foreach($imageList as $image){
	if($image) $imgNum++;
}
$query = "SELECT id, name FROM #__pr_image WHERE product_id = ".$item->product_id;
$db->setQuery($query);
$images = $db->loadObjectList();
$imgNum += count($images);

$db->setQuery("SELECT auction_date FROM #__auction_date WHERE id = 2");
$status = $db->loadResult();

$query = "SELECT id FROM #__auction WHERE product_id = ( SELECT p.id FROM #__pr_product p INNER JOIN #__auction a ON p.id = a.product_id WHERE p.katno < ".$item->katno." AND p.bought = 0 AND a.closed = 0 AND a.published = 1 ORDER BY p.katno DESC LIMIT 0,1)";
$db->setQuery($query);
$back = $db->loadResult();

$query = "SELECT id FROM #__auction WHERE product_id = ( SELECT p.id FROM #__pr_product p INNER JOIN #__auction a ON p.id = a.product_id WHERE p.katno > ".$item->katno." AND p.bought = 0 AND a.closed = 0 AND a.published = 1 ORDER BY p.katno ASC LIMIT 0,1)";
$db->setQuery($query);
$next = $db->loadResult();
if(!$back && !$next){
	$back_link = "javascript:void(0);";
	$next_link = "javascript:void(0);";
} else if(!$back){
	$back_link = "javascript:void(0);";
	$next_link = "index.php?option=com_auction&view=list&auc_id=".($next)."&Itemid=10";
} else if(!$next){
	$back_link = "index.php?option=com_auction&view=list&auc_id=".($back)."&Itemid=10";
	$next_link = "javascript:void(0);";
} else {
	$back_link = "index.php?option=com_auction&view=list&auc_id=".($back)."&Itemid=10";
	$next_link = "index.php?option=com_auction&view=list&auc_id=".($next)."&Itemid=10";
}

$db->setQuery("SELECT auction_date FROM #__auction_date WHERE id = 1");
$auction_date = $db->loadResult();
$auctionDateArr = explode('-', $auction_date);

$db->setQuery('SELECT max_price FROM #__auction_auto WHERE user_id = '.$user->id.' AND auc_id = '.$item->id);
$max_price = $db->loadResult();

$document = JFactory::getDocument();
$document->setTitle('Dansk Automobil Børs - Online auktion - '.$item->katno .'-'. $item->model);
?>
<link rel="stylesheet" type="text/css" href="<?php echo $template;?>fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript" src="<?php echo $template;?>fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="<?php echo $template;?>fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="<?php echo $template;?>js/jquery.json-2.2.min.js"></script>
<style type="text/css">@import "<?php echo $template;?>countdown/jquery.countdown.css";</style> 
<script type="text/javascript" src="<?php echo $template;?>countdown/jquery.countdown.js"></script>
<script type="text/javascript" src="<?php echo $template;?>countdown/jquery.countdown-da.js"></script>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js" ></script>
<link href="<?php echo $template;?>css/reveal.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo $template;?>js/jquery.reveal.js"></script>
<script type="text/javascript">
function postFacebookWallDetail(urlencode){
    t=document.title; 
    window.open('http://www.facebook.com/sharer.php?u='+urlencode+'&v=<?php echo time();?>','sharer','toolbar=0,status=0,width=626,height=436'); 
    return false; 
}
function popUpLive(){
	window.open( '<?php echo JURI::base();?>client_livestream.html', '', 'toolbar=0,status=0,height=350,width=465' );
	return false;
}
</script>
<script type="text/javascript">
jQuery(document).ready(function(){
	jQuery("#mycarouse").jCarouselLite({
		btnNext: ".next1",
		btnPrev: ".prev1",
		visible : 4,
		scroll: 1,
		speed : 400
	});
	
	jQuery("a[rel=example_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Billede ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	removeLable = function(){ 
		$('.label-maxprice').css('display','none');
		$('.txt-price').focus();
	}
	popUp = function(){
		var go = confirm("Du har skal betale depostium for at byde. Vil du gå til betaling TRYK OK");
		if (go == true){
			location.href='index.php?option=com_user&view=register&layout=payment&userid=<?php echo $user->id;?>&Itemid=13&active=1';
		}
		else{
			return false;
		}
	}
});	
</script>
<style>
.init_img{
	display:inline-block;
	height:61px;
	width:98px;
}
#fancybox-title{display:none !important}
</style>
<p>
	<span class="float_left f28"><?php echo $item->katno;?> - <?php echo $item->model;?></span>
    <span class="link-login"><a href="index.php?option=com_user&view=user&layout=profile&Itemid=13"><?php if($user->guest==0) {echo  "Min Profil";} ;?></a><a href="index.php?option=com_user&view=login&task=logout&Itemid=13" class="m12l"><?php if($user->guest==0) {echo  "Log ud";};?></a></span>
</p>
<div class="cb"></div>
<div class="tt"></div>
<div style="margin:5px 0; font-size:16px; font-weight:bold;"><a href="index.php?option=com_ecommerce&view=katalog&Itemid=8"><< tilbage</a></div>
<div class="">
	<div class="">
    	<div class="w462 float_left">
        	<div class="box_katalog">
            	<?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$item->image."&w=447&h=296&zc=1' title='".$item->model."' alt='".$item->model ."' />";?>
            </div>
            <div class="w451">
            	<?php if($imgNum > 4){?>
              	<div class="nav_prev"><a class="prev1" href="javascript:;"><img src="<?php echo $template;?>images/icon_prev1.png.jpg"></a></div>
                <?php }?>
              	<div id="mycarouse" class="thunb_katalog float_left" style="overflow: hidden;">
                    <ul class="list_img">
                    	<?php if($item->image){?>
                        <li>
                        <a rel="example_group" href="<?php echo JURI::root(false).'components/com_ecommerce/imgupload/'.$item->image;?>" title="" class="init_img">
                        <?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$item->image."&w=98&h=61&zc=1' title='".$item->model."' alt='".$item->model ."' />";?>
                        </a>
                        </li>
                        <?php }?>
                        <?php if($item->image1){?>
                        <li>
                        <a rel="example_group" href="<?php echo JURI::root(false)."components/com_ecommerce/imgupload/".$item->image1;?>" class="init_img" >
                        <?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$item->image1."&w=98&h=61&zc=1' title='".$item->model."' alt='".$item->model ."' />";?>
                        </a>
                        </li>
                        <?php }?>
                        <?php if($item->image2){?>
                        <li>
                        <a rel="example_group" href="<?php echo JURI::root(false)."components/com_ecommerce/imgupload/".$item->image2;?>" class="init_img">
                        <?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$item->image2."&w=98&h=61&zc=1' title='".$item->model."' alt='".$item->model ."' />";?>
                        </a>
                        </li>
                        <?php }?>
                        <?php if($item->image3){?>
                        <li>
                        <a rel="example_group" href="<?php echo JURI::root(false)."components/com_ecommerce/imgupload/".$item->image3;?>" class="init_img">
                        <?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$item->image3."&w=98&h=61&zc=1' title='".$item->model."' alt='".$item->model ."' />";?>
                        </a>
                        </li>
                        <?php }?>
                        <?php if($item->image4){?>
                        <li>
                        <a rel="example_group" href="<?php echo JURI::root(false)."components/com_ecommerce/imgupload/".$item->image4;?>" class="init_img">
                        <?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$item->image4."&w=98&h=61&zc=1' title='".$item->model."' alt='".$item->model ."' />";?>
                        </a>
                        </li>
                        <?php }?>
                        <?php foreach($images as $itemImage){?>
                        <li>
                        <a rel="example_group" href="<?php echo JURI::root(false)."components/com_ecommerce/imgupload/".$itemImage->name;?>" class="init_img">
                        <?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$itemImage->name."&w=98&h=61&zc=1' title='".$item->model."' alt='".$item->model ."' />";?>
                        </a>
                        </li>
                        <?php }?>
                    </ul>
                	<div class="cb"></div>
              	</div>
                <?php if($imgNum > 4){?>
              	<div class="nav_next"><a class="next1" href="javascript:;"><img src="<?php echo $template;?>images/icon_next1.png.jpg" /></a></div>
                <?php }?>
              	<div class="cb"></div>
            </div>
            <?php if(!$user->get('guest') && $status){?>
            <a class="m15t" style="display:block;" href="javascript:void(0);" onclick="popUpLive();"><img src="images/btn_livestream.jpg" /></a>
            <?php }?>
            <!-- <div class="box_katalog">
				 
			</div>-->
            <div class="w451">
            	<?php /*
				if($item->video){
				?>
                <div class="box_text_katalog_detail">
                    <iframe width="447" height="250" frameborder="0" allowfullscreen="" src="<?php echo $item->video;?>"></iframe>
                </div>
                <?php }*/?>
                <div class="box_text_katalog_detail m20t">
                    <div class="title_text_katalog">Information</div>
                    <div class="p10">
                        <?php echo $item->comment;?>
                    </div>
                </div>
                <div class="cb"></div>
			</div>
            <?php if(!$status){?>
            <div class="thunb_online">
            	<a class="float_left" href="<?php echo $back_link;?>"><img src="templates/tpl_automobil/images/back.png" /></a>
                <a class="float_left m12l" href="<?php echo $next_link;?>"><img src="templates/tpl_automobil/images/next.png" /></a>
            </div>
            <?php }?>
		</div>
        <div class="w276 float_right">
            <div class="box_derip_katalog1 box_text_katalog_detail">
            <div class="title_text_katalog"><a href="tilmeld-bil.html">Tilmeld din bil</a></div>
              <div class="p10">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                  	<td colspan="2" align="left"><a onclick="postFacebookWallDetail('<?php echo "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];?>')" href="javascript:void(0);"><img src="images/sharefb.jpg" alt=""/></a></td>
                  </tr>
                  <tr>
                    <td width="35%"><strong>Tilmelding af bilen Biltype: </strong></td>
                    <td width="65%"><?php echo $item->car_type;?></td>
                  </tr>
                  <tr>
                    <td><strong>Mærke/Model:</strong></td>
                    <td><?php echo $item->model;?></td>
                  </tr>
                  <tr>
                    <td><strong>Brændstof:</strong></td>
                    <td><?php echo $item->fuel;?></td>
                  </tr>
                  <tr>
                    <td><strong>1st Reg.: </strong></td>
                    <td><?php echo $item->register_day;?></td>
                  </tr>
                  <tr>
                    <td><strong>Seneste syn:</strong> </td>
                    <td><?php echo $item->view_day;?></td>
                  </tr>
                  <tr>
                    <td><strong>Skal synes: </strong></td>
                    <td><?php if($item->registry) echo "Ja"; else echo "Nej";?></td>
                  </tr>
                  <tr>
                    <td><strong>Stand/Kategori:</strong></td>
                    <td><?php echo $item->stand;?></td>
                  </tr>
                  <tr>
                    <td><strong>Km.stand: </strong></td>
                    <td><?php echo $item->km;?></td>
                  </tr>
                   <tr>
                    <td><strong>Registeringsnummer: </strong></td>
                    <td><?php echo $item->carid;?></td>
                  </tr>
                  <?php if($item->color){?>
                   <tr>
                    <td><strong>Farve: </strong></td>
                    <td><?php echo $item->color;?></td>
                  </tr>
                  <?php }?>
                   <?php /*if($item->color_type){?>
                   <tr>
                    <td><strong>Lakstand: </strong></td>
                    <td><?php echo $item->color_type;?></td>
                  </tr>
                  <?php }?>
                   <?php if($item->cabin_color){?>
                   <tr>
                    <td><strong>Kabinefarve: </strong></td>
                    <td><?php echo $item->cabin_color;?></td>
                  </tr>
                  <?php }*/?>
                   <?php if($item->chassis){?>
                   <tr>
                    <td colspan="2"><strong>Stelnummer: </strong><?php echo $item->chassis;?></td>
                  </tr>
                  <?php }?>
                </table>
              </div>
            </div>
            
            <div class="cb"></div>
            <div class="m5t"></div>
            <?php if(!$user->get('guest') && ($user->get('checkout_status') || $user->get('vip'))){?>
            <?php if($item->show_status){?>
            <h5 style="padding-left:3px;"><b>MINDSTEPRIS <span class="red_color" id="desired"><?php if($item->currentprice >= $item->desiredprice) echo 'OPNÅET';else echo 'IKKE OPNÅET';?></span></b></h5>
            <?php }?>
            <h5 style="padding-left:3px; text-align:center;"><b><a data-reveal-id="myModal-<?php echo $item->id;?>" href="#">Nuværende bud</a></b></h5>
            <div class="bid-price">DKK <span id="currentPriceLabel"></span>,-</div>
            <?php /*if($status){?>
            <div class="bid-price-next">DKK <span id="nextPriceLabel"></span>,-</div>
            <?php }*/?>
            <div id="displayAuction" <?php if($item->closed == 0){?>style="display: block;"<?php } else {?>style="display: none;"<?php }?>>
            	<?php if($status){?>
                <div>
                    <a class="btn m10t" href="javascript:void(0);" onclick="<?php if(!$user->get('guest')) echo 'sumNextBid(100);'; else echo "userLogin();";?>"><img src="<?php echo $template?>images/btn_100.jpg" /></a>
                    <a class="btn m10t" href="javascript:void(0);" onclick="<?php if(!$user->get('guest')) echo 'sumNextBid(500);'; else echo "userLogin();";?>"><img src="<?php echo $template?>images/btn_500.jpg" /></a>
                    <div class="cb"></div>
                </div>
               
                <div class="cb"></div>
                <a class="btn m10t" href="javascript:void(0);" onclick="<?php if(!$user->get('guest')) echo 'sumNextBid(1000);'; else echo "userLogin();";?>"><img src="<?php echo $template?>images/btn_1000.jpg" /></a>
                <?php }?>
                 <div class="m15t">
                 	<a class="tooltip-eps f-l m20t" href="javascript:void(0);" style="z-index:10;" data-reveal-id="iModal"><img src="<?php echo $template;?>images/ico_info.png" alt="" /> 
                       <!-- <div class="wrapper-tooltip">            
                            <div class="tooltip-top"></div>
                            <div class="tooltip-content">
                                Try her
                            </div>
                            <div class="tooltip-bottom"></div>
                        </div>-->
                    </a>
                    <div class="bid-max">
                    <label class="label-maxprice" onclick="removeLable();" <?php if($max_price) echo 'style="display:none;"'; else echo 'style="display:block;"';?>>DIT MAKSIMUMBUD</label>
                    <input type="text" class="txt-price" value="<?php if($max_price) echo $max_price;?>" onclick="removeLable();" name="max_price" id="max_price"/>
                    <a  href="javascript:void(0);" onclick="<?php if($user->get('guest')) echo 'userLogin();';else echo 'startAuto();';?>" id="btStartAuto" <?php if($max_price) echo 'style="display:none;"'; else echo 'style="display:block;"';?>><img src="<?php echo $template?>images/btn_max_bid.jpg" /></a>
                    <a  href="javascript:void(0);" onclick="stopAuto();" id="btStopAuto" <?php if(!$max_price) echo 'style="display:none;"'; else 'style="display:block;"';?>><img src="<?php echo $template?>images/btn_max_bid.jpg" /></a>
                    <span id="loadingPrice" style="display:block; clear:both; text-align:center;"></span>
                    </div>
                </div>
            </div>
          	<?php } else {
				if($user->get('guest')){
			?>
            	<a href="index.php?option=com_user&view=login&Itemid=13"><img src="images/here.png" /></a>
            <?php
				} else {
					?>
                <a href="javascript:void(0);" onclick="popUp();"><img src="images/here.png" /></a>
            <?php
				}
			}?>
        </div>
        <p class="cb"></p>
        <?php if($item->placering == "Dansk Automobil Børs") echo $this->loadTemplate('info'); else echo $this->loadTemplate('info1');?>
    </div>
</div>
<div id="myModal-<?php echo $item->id;?>" class="reveal-modal">
    <iframe src="index.php?option=com_ecommerce&view=detail&layout=last_history&tmpl=component&auc_id=<?php echo $item->id;?>&user_id=<?php echo $user->id;?>" style="width:510px; height:165px;overflow:hidden; border:none;"></iframe>
    <a class="close-reveal-modal">&#215;</a>
</div>
 <div id="iModal" class="reveal-modal" style="height:520px; top:40px;">
    På onlineauktionen kan du vælge enten at aflægge dit bud enkeltvis undervejs når auktionen kører eller benytte dig af maxbud funktionen.<br /><br /><strong>Maxbud – en smart måde at byde på hos Dansk Automobil Børs</strong><br /><br />Maxbud er en funktion, som gør, at du kan byde på en auktion selvom du ikke har tid til at sidde ved din computer, når auktionen kører. Auktionssystemet byder automatisk budsummen op for dig indtil der er budt op til det beløb, du maksimalt vil byde.<br /><br />Dette er en nyttig funktion hvis du får tekniske problemer undervejs i auktionen, eller hvis du har flere effekter at holde øje med på auktionen.<br /><br />Dit maxbud er nødvendigvis ikke det, du kommer til at betale for varen, for auktionssystemet sikrer at hammerslaget bliver billigst muligt og maksimalt til den sum, som du har angivet som dit maxbud.<br /><br /><strong>Sådan fungerer det!</strong><br /><br />Et maxbud fungerer som en ”autopilot”. Når du lægger et bud ind, så tjekker systemet om du har højeste bud. Hvis du har højeste bud vil auktionssystemet automatisk overbyde eksisterende aktuelle bud, så dit bud altid er højest. Det bliver systemet ved med indtil din maksimale pris (maxbud) er opnået. Andre steder kaldes systemet også for ”autobud”.<br /><br />Hvis dit maxbud ikke er højest, fordi der ligger et endnu højere maxbud fra en anden byder, så vil dit maxbud blive næste aktuelle bud, men vil straks herefter blive overbudt af den, som har det højeste maxbud. Du kan herefter bestemme, om du evt. vil byde mere, således dit maxbud hæves og du herved evt. vinder auktionen. <br /><br />I tilfælde af at du bliver overbudt, vil du automatisk modtage en besked pr. e-mail. <br /><br /><strong>Mindstepris</strong> <br /><br />Uanset hvilke bud der kommer, så skal alle vindende bud være lig med eller højere end en eventuel mindstepris. En mindstepris er sælgers (indsætters) ønskede minimumspris for et slag kan finde sted. Hvis ingen bud er lig med eller højere, er varen ikke solgt!
    <a class="close-reveal-modal">&#215;</a>
</div>
<input type="hidden" id="currentPrice" value="<?php echo $item->currentprice;?>" />
<input type="hidden" id="nextPrice" value="" />
<input type="hidden" id="profileNumber" value="<?php echo $user->get('profile_number');?>" />
<script language="javascript" type="text/javascript">
jQuery(document).ready(function(){
	var bid = 0; i = 1;
	jQuery("#nextPrice").val(parseInt(jQuery("#currentPrice").val()) + 1000);
	jQuery("#currentPriceLabel").html(jQuery("#currentPrice").val());
	
	checkMaxPrice = function(maxprice){
		if(maxprice%100 != 0){
			alert('Venligst indtast hele hundrede beløb!');
			return false;
		}
		return true;
	}
	
	startAuto = function(){
		var max_price = parseFloat(jQuery("#max_price").val());
		if(!checkMaxPrice(max_price)){return false;}		
		$("#loadingPrice").html('<img src="templates/tpl_automobil/images/loading.gif">');
		jQuery("#btStartAuto").css('display','none');
		if(max_price){
			jQuery.ajax({
				type: 'POST',
				url: ('<?php echo $this->baseurl ?>/index.php?option=com_auction&task=startAuto'),
				data: {max_price: max_price, user_id: <?php echo $user->id;?>, auc_id: <?php echo $item->id;?>},
				success: function(result){
					if(parseInt(result) == 1){
						$("#loadingPrice").html('');
						alert('Auto bud er sat op');
						jQuery("#btStopAuto").css('display','block');						
					} else {
						alert('Mislykkes');
					}
				}
			});
		} else {
			alert('Indtast venligst max pris');
			jQuery("#max_price").focus();
			return false;
		}
	}
	
	stopAuto = function(){
		$("#loadingPrice").html('<img src="templates/tpl_automobil/images/loading.gif">'); 
		jQuery("#btStopAuto").css('display','none');
		jQuery.ajax({
			type: 'POST',
			url: ('<?php echo $this->baseurl ?>/index.php?option=com_auction&task=stopAuto'),
			data: {user_id: <?php echo $user->id;?>, auc_id: <?php echo $item->id;?>},
			success: function(result){
				if(parseInt(result) == 1){
					$("#loadingPrice").html('');
					alert('Autobud er sat på pause, indtast venligst den nye pris');
					jQuery("#btStartAuto").css('display','block');
					
					$('.txt-price').val('');
					$('.txt-price').focus();
				} else {
					alert('Mislykkes');
				}
			}
		});
	}
	
	sumNextBid = function(money){
		if(bid == 0){
			jQuery("#nextPrice").val(parseInt(jQuery("#currentPrice").val()) + money);
		} else {
			jQuery("#nextPrice").val(parseInt(jQuery("#nextPrice").val()) + money);
		}
		bid = 1;
		sendPrice();
	}
		
	loadPrice = function() {
		jQuery.ajax({
			type: 'POST',
			url: ('<?php echo $this->baseurl ?>/index.php?option=com_auction&task=loadPrice'),
			data: {auc_id: <?php echo $item->id;?>, price: jQuery("#currentPrice").val()},
			success: function(result){
				result=jQuery.evalJSON(result);
				if(parseInt(result.closed) == 0){
					if( parseInt(result.price) != parseInt( jQuery("#currentPrice").val() ) ){
						jQuery("#currentPrice").val(parseInt(result.price));
						jQuery("#currentPriceLabel").html(jQuery("#currentPrice").val());
						jQuery('#displayAuction').css('display','block');
					}
					loadPrice();
				} else {
					jQuery('#displayAuction').css('display','none');
					location.href = "index.php?option=com_auction&view=list&auc_id=<?php echo $next;?>&Itemid=10";
										
				}
			},
			dataType: 'JSON'
		});
    };
	
	loadStatus = function(){
		jQuery.ajax({
			type: 'POST',
			url: ('<?php echo $this->baseurl ?>/index.php?option=com_auction&task=loadStatus'),
			data: {status : <?php echo $status;?>},
			success: function(result){
				if(parseInt(result))
					location.href = "index.php?option=com_auction&view=list&Itemid=10";
			}
		});
	}
	
	<?php if(!$user->get('guest')){?>
	if(i){
		loadPrice();
		i = 0;
	}
	setInterval('loadStatus()', 2000);
	<?php }?>	
	
	sendPrice = function(){
		i = 1;
		jQuery.ajax({
			type: 'POST',
			url: ('<?php echo $this->baseurl ?>/index.php?option=com_auction&task=sendPrice'),
			data: {price: jQuery("#nextPrice").val(), user_id: <?php echo $user->id;?>, auc_id: <?php echo $item->id;?>},
			success: function(result){
				result=jQuery.evalJSON(result);
				if(parseInt(result.closed) == 0){
					bid = 0;
					jQuery("#currentPrice").val(parseInt(result.price));
					jQuery("#currentPriceLabel").html(jQuery("#currentPrice").val());
					i = 0;
					loadPrice();
				} else {
					alert('Denne auktion er lukket');
				}
			},
			dataType: 'JSON'
		});
	}
});
</script>
